package com.rzjm.exercise.module.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rzjm.exercise.common.base.data.DataTableLayUI;
import com.rzjm.exercise.common.base.service.impl.BaseServiceImpl;
import com.rzjm.exercise.module.dao.DepartmentDao;
import com.rzjm.exercise.module.domain.Department;
import com.rzjm.exercise.module.service.DepartmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 方法说明： 实现层
 * @author Mr.Zhou
 * @date 2020/3/17
 */
@Service
public class DepartmentServiceImpl extends BaseServiceImpl<DepartmentDao, Department> implements DepartmentService {
    @Resource
    private DepartmentDao departmentDao;
    @Override
    public DataTableLayUI<Department> getListPage(DataTableLayUI<Department> condition) {
        Page<Department> page = new Page<>(condition.getPage(), condition.getLimit());
        List<Department> list = departmentDao.getListPage(page, condition.getSearchParams());
        condition.setCount(page.getTotal());
        condition.setData(list);
        condition.setTotalPages(page.getPages());
        condition.setCode(0);
        condition.setMsg("success");
        return condition;
    }
}
